home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovieAllocine.py < prev    next >
Text File  |  2008-11-17  |  4KB  |  125 lines

  1. # -*- coding: UTF-8 -*-
  2.  
  3. __revision__ = '$Id: PluginMovieIMDB.py 176 2006-02-01 12:07:26Z iznogoud $'
  4.  
  5. # Copyright (c) 2005-2006 Vasco Nunes, Piotr Ozarowski
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, orprint
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  20.  
  21. # You may use and distribute this software under the terms of the
  22. # GNU General Public License, version 2 or later
  23.  
  24. import gutils
  25. import movie
  26. import string
  27.  
  28. plugin_name = "Allocine"
  29. plugin_description = "Internet Movie Database"
  30. plugin_url = "www.allocine.fr"
  31. plugin_language = _("French")
  32. plugin_author = "Pierre-Luc Levy"
  33. plugin_author_email = ""
  34. plugin_version = "0.6"
  35.  
  36. class Plugin(movie.Movie):
  37.     def __init__(self, id):
  38.         self.movie_id = id
  39.         self.url = "http://www.allocine.fr/film/fichefilm_gen_cfilm=%s.html" % str(self.movie_id)
  40.  
  41.     def get_image(self):
  42.         self.image_url = gutils.trim(self.page,"Poster","Date de sor")
  43.         self.image_url = gutils.after(self.image_url,"activerlientexte.inc")
  44.         self.image_url = gutils.trim(self.image_url,"<img src=\"","\"")
  45.  
  46.     def get_o_title(self):
  47.         self.o_title = ""
  48.         self.o_title = gutils.trim(self.page,"Titre original : <i>","</i>")
  49.         if (self.o_title==''):
  50.             self.o_title = gutils.trim(self.page,"<title>","</title>")
  51.  
  52.     def get_title(self):
  53.         self.title = gutils.trim(self.page,"<title>","</title>")
  54.  
  55.     def get_director(self):
  56.         self.director = gutils.trim(self.page,"<h4>R├⌐alis├⌐ par ","</a></h4>")
  57.  
  58.     def get_plot(self):
  59.         self.plot = gutils.trim(self.page,"Synopsis</b></h3></td></tr></table>","</h4>")
  60.         self.plot = gutils.after(self.plot,"<h4>")
  61.  
  62.     def get_year(self):
  63.         self.year = gutils.trim(self.page,"Ann├⌐e de production : ","</h4>")
  64.  
  65.     def get_runtime(self):
  66.         self.runtime = ""
  67.         self.runtime = gutils.trim(self.page,"<h4>Dur├⌐e : ","min.</h4> ")
  68.         if self.runtime:
  69.             self.runtime = str (int(gutils.before(self.runtime,"h"))*60 + int(gutils.after(self.runtime,"h")))
  70.  
  71.     def get_genre(self):
  72.         self.genre = gutils.trim(self.page,"<h4>Genre : ","</h4>")
  73.         self.genre = gutils.strip_tags(self.genre)
  74.  
  75.     def get_cast(self):
  76.         self.cast = ""
  77.         self.cast = gutils.trim(self.page,"<h4>Avec ","</h4>")
  78.         self.cast = gutils.strip_tags(self.cast)
  79.         self.cast = string.replace(self.cast,", ", "\n")
  80.  
  81.     def get_image(self):
  82.         self.classification = ""
  83.  
  84.     def get_studio(self):
  85.         self.studio = ""
  86.  
  87.     def get_o_site(self):
  88.         self.o_site = ""
  89.  
  90.     def get_site(self):
  91.         self.site = "http://www.allocine.fr/film/fichefilm_gen_cfilm=%s.html" % self.movie_id
  92.  
  93.     def get_trailer(self):
  94.         self.trailer = "http://www.allocine.fr/film/video_gen_cfilm=%s.html" % self.movie_id
  95.  
  96.     def get_country(self):
  97.         self.country = gutils.trim(self.page,"<h4>Film ",".</h4> ")
  98.  
  99.     def get_rating(self):
  100.         self.rating = gutils.trim(self.page, "Spectateurs</a> ", "</h4>")
  101.         self.rating = gutils.trim(self.rating, "etoile_", ".gif")
  102.         if self.rating:
  103.             self.rating = str(float(int(self.rating)*2.25))
  104.  
  105. class SearchPlugin(movie.SearchMovie):
  106.  
  107.     def __init__(self):
  108.         self.original_url_search    = "http://www.allocine.fr/recherche/?motcle="
  109.         self.translated_url_search    = "http://www.allocine.fr/recherche/?motcle="
  110.  
  111.     def search(self,parent_window):
  112.         self.open_search(parent_window)
  113.         self.sub_search()
  114.         return self.page
  115.  
  116.     def sub_search(self):
  117.         self.page = gutils.trim(self.page,"Recherche : <b>", "<h3><b>Articles <h4>");
  118.  
  119.     def get_searches(self):
  120.         elements = string.split(self.page,"<td colspan=\"2\" height=\"1\" valign=\"top\"><hr /></td>")
  121.         if (elements[0]<>''):
  122.             for element in elements:
  123.                 self.ids.append(gutils.trim(element,"/film/fichefilm_gen_cfilm=",".html"))
  124.                 self.titles.append(gutils.strip_tags(gutils.convert_entities(gutils.trim(element,"link1\">","</a>"))))
  125.